package com.gisocn.onemap.ui.alert;

import android.app.Dialog;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.fragment.app.BaseDialogFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemClickListener;
import com.gisocn.onemap.databinding.AlertLayerSelectBinding;
import com.gisocn.onemap.model.LayerInfoBean;
import com.gisocn.onemap.model.LayerSelectBean;
import com.gisocn.onemap.sgzx.R;
import com.gisocn.onemap.ui.activity.MainActivity;
import com.gisocn.onemap.ui.adapter.LayerSelectAdapter;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes2.dex */
public class AlertLayerSelect extends BaseDialogFragment<AlertLayerSelectBinding> {
    private View anchorView;
    private List<LayerInfoBean> layerInfoList;
    private LayerSelectAdapter layerSelectAdapter;
    private List<LayerSelectBean> layerSelectDataList = new ArrayList();
    private MainActivity mainActivity;
    private OnLayerSelectCallback onLayerSelectCallback;

    /* loaded from: classes2.dex */
    public interface OnLayerSelectCallback {
        void selectCallback(LayerSelectBean layerSelectBean);
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected void dismissEvent() {
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected int getLayoutId() {
        return R.layout.alert_layer_select;
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected void initListener() {
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected boolean isBottomDialog() {
        return false;
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected boolean isTopDialog() {
        return true;
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected boolean isTranslucentDialog() {
        return false;
    }

    public AlertLayerSelect setAnchorView(View view) {
        this.anchorView = view;
        return this;
    }

    public AlertLayerSelect setMainActivity(MainActivity mainActivity) {
        this.mainActivity = mainActivity;
        return this;
    }

    public AlertLayerSelect setLayerInfoList(List<LayerInfoBean> list) {
        this.layerInfoList = list;
        return this;
    }

    public AlertLayerSelect setOnLayerSelectCallback(OnLayerSelectCallback onLayerSelectCallback) {
        this.onLayerSelectCallback = onLayerSelectCallback;
        return this;
    }

    @Override // androidx.fragment.app.BaseDialogFragment
    protected void initView() {
        if (this.layerSelectAdapter == null) {
            ((AlertLayerSelectBinding) this.mViewDataBinding).rvLayerData.setLayoutManager(new LinearLayoutManager(this.context));
            this.layerSelectAdapter = new LayerSelectAdapter(R.layout.item_layer_select, this.layerSelectDataList);
            ((AlertLayerSelectBinding) this.mViewDataBinding).rvLayerData.setAdapter(this.layerSelectAdapter);
            this.layerSelectAdapter.setOnItemClickListener(new OnItemClickListener() { // from class: com.gisocn.onemap.ui.alert.AlertLayerSelect.1
                @Override // com.chad.library.adapter.base.listener.OnItemClickListener
                public void onItemClick(BaseQuickAdapter<?, ?> baseQuickAdapter, View view, int i) {
                    if (i >= AlertLayerSelect.this.layerSelectDataList.size()) {
                        return;
                    }
                    AlertLayerSelect.this.dismiss();
                    LayerSelectBean layerSelectBean = (LayerSelectBean) AlertLayerSelect.this.layerSelectDataList.get(i);
                    if (AlertLayerSelect.this.onLayerSelectCallback != null) {
                        AlertLayerSelect.this.onLayerSelectCallback.selectCallback(layerSelectBean);
                    }
                }
            });
        }
        getLayerData();
    }

    /* JADX WARN: Removed duplicated region for block: B:45:0x00e3  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private void getLayerData() {
        /*
            Method dump skipped, instructions count: 307
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.gisocn.onemap.ui.alert.AlertLayerSelect.getLayerData():void");
    }

    @Override // androidx.fragment.app.Fragment
    public void onResume() {
        super.onResume();
        Dialog dialog = getDialog();
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
        Window window = dialog.getWindow();
        View view = this.anchorView;
        if (view != null) {
            int[] iArr = new int[2];
            view.getLocationOnScreen(iArr);
            WindowManager.LayoutParams attributes = window.getAttributes();
            attributes.gravity = 51;
            attributes.x = iArr[0];
            attributes.y = (int) (iArr[1] + this.context.getResources().getDimension(R.dimen.dp_30));
            attributes.width = -2;
            attributes.height = -2;
            window.setAttributes(attributes);
        }
    }
}
